var klay = require('klayjs');

var graph = {
  "id": "root",
  "properties": {
      "direction": "RIGHT", "spacing": 40
  },
  "children": [{"id": "n1", "width": 40, "height": 40}, 
               {"id": "n2", "width": 40, "height": 40}],
  "edges": [{"id": "e1", "source": "n1", "target": "n2"}]
};

klay.layout({
  graph: graph,
  options: {spacing: 20},
  success: function(g) { console.log(g); }
});

var klaysvg = require('klayjs-svg');

var renderer = new klaysvg.Renderer();
var svg = renderer.toSvg(graph);
console.log(svg);